home *** CD-ROM | disk | FTP | other *** search
-
- Program SPACeDELeter;
-
- { Written by James A. Grettum
- . 1321 So. 23rd St., Suite A
- . PO Box 7055
- . Fargo, ND 58103
- . (701)293-6646
- .
- . Purpose to DELete unwanted leading spaces from a text
- . file. The program prompts the user for the maximum
- . number of leading spaces to delete. This may come
- . in very handy for using PP.COM.
- .
- . Started April 6, 1985
- .
- . Last
- . Update April 7, 1985
- .
- .
- }
-
- Var
- InFile,
- OutFile : Text[$800];
- Line,
- Answer : string[240];
- I,N,
- NumLines,
- MaxDelete,
- Scrnclr : Integer;
- StillSpace,
- FileFound : Boolean;
- NameInFile,
- NameOutFile : String[20];
-
- Procedure OpenInFile; {Procedure to check for Input File}
- Begin
- Repeat
- Gotoxy(10,7);
- Write('Enter the name of the Input file : ');
- ReadLn(NameInFile);
- Gotoxy(10,8);
- ClrEol;
- Assign(Infile,NameInFile);
- {$I-}
- Reset(InFile) {$I+} ;
- FileFound := (IOresult = 0);
- If not FileFound
- then
- begin
- Gotoxy(10,8);
- sound(440);
- Delay(500);
- Nosound;
- Write('CANNOT FIND FILE "',NameInFile,'" Try another name.');
- end;
- Until FileFound;
- End;
-
- Procedure CheckOutFile; {Procedure to check for OutputFile}
- Begin
- Repeat
- Gotoxy(10,9);
- Write('Enter the name for the output file: ');
- ReadLn(NameOutFile);
- Gotoxy(10,10);
- ClrEol;
- Assign(OutFile,NameOutFile);
- {$I-}
- Reset(OutFile) {$I+} ;
- FileFound := (IOresult = 0);
- If FileFound
- then
- begin
- Gotoxy(10,10);
- sound(440);
- Delay(500);
- Nosound;
- Close(OutFile);
- Write('That file already exists!! Continue? (y): ');
- Read(Answer);
- If Upcase(Answer)='Y'
- then FileFound := False;
- end;
- Until not FileFound;
- End;
-
- begin
- ClrScr;
- TextBackground(7);
- TextColor(0);
- Gotoxy(28,1);
- Write(' SPACe DELeter ');
-
- Gotoxy(10,3);
- Write(' This program will delete unwanted leading ');
- Gotoxy(10,4);
- Write(' spaces in a text file. You can set the maximum ');
- Gotoxy(10,5);
- Write(' spaces to be deleted. ');
- NormVideo;
- OpenInFile;
- CheckOutFile;
- Gotoxy(10,11);
- Write('Enter the maximum number of spaces to delete: ');
- ReadLn(MaxDelete);
- Reset(InFile);
- Assign(OutFile,NameOutFile);
- Rewrite(OutFile);
- Gotoxy(10,13);
- Write('The Input file is ' + NameInFile);
- Gotoxy(10,15);
- Write('The Output file is ' + NameOutFile);
- Gotoxy(10,17);
- Write('Working on Line: ');
- WriteLn(' ');
- Scrnclr := 0;
- NumLines := 0;
-
- while not EOF(InFile) do
- begin
-
- ReadLn(InFile,Line);
- Numlines := Numlines + 1;
- N := 0;
- StillSpace := True;
- {WriteLn(Line);}
- While StillSpace Do
- Begin
- I := N+1;
- If Line[I]=' '
- then
- begin
- N := N+1;
- if n=maxdelete
- then
- StillSpace := False;
- end
- Else StillSpace := False;
- end;
- DELETE(Line,1,N);
- GotoXY(28,17);
- WriteLn(NumLines);
- WriteLn(OutFile,Line);
- end;
-
- WriteLn(' ');
- WriteLn('All Done');
- Close(InFile);
- Close(OutFile);
- end.
-